﻿using System;
using TidyBlog.Data.Mapping;

namespace TidyBlog.Data
{
    /// <summary>
    /// 排序列
    /// </summary>
    public class SortColumn
    {
        /// <summary>
        /// 获取或设置排序的列
        /// </summary>
        public string Column { get; set; }
        /// <summary>
        /// 获取或设置排序方式，默认为ASC
        /// </summary>
        public OrderWay OrderWay { get; set; }


        public SortColumn()
        {
            OrderWay = OrderWay.ASC;
        }
        /// <summary>
        /// 根据列名初始化
        /// </summary>
        /// <param name="column">列名</param>
        public SortColumn(string column)
        {
            Column = column;
            OrderWay = OrderWay.ASC;
        }
        /// <summary>
        /// 根据数据列特性初始化
        /// </summary>
        /// <param name="colAttr">数据列特性</param>
        public SortColumn(ColumnAttribute colAttr)
        {
            Column = colAttr.Name;
            OrderWay = colAttr.OrderWay == 0 ? OrderWay.ASC : OrderWay.DESC;
        }
    }
}
